package cate.common.table.farm.forbidden.row.fm;

import cate.common.table.ERow;
import cate.common.table.XSSFRowWrap;
import cp.solution.util.str.Str;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

@NoteClass(value = "混沌之地关卡")
public class FMChapterRow extends ERow {
    @NoteField(value = "难度ID")
    public int difficulty;

    @NoteField(value = "关卡ID")
    public int level;

    @NoteField(value = "挑战ID")
    public String challengeStr;

    @NoteField(value = "挑战奖励分组")
    public String rwdStr;

    @NoteField(value = "怪物配置")
    public String insTplStr;

    @Override
    public void parse(XSSFRowWrap xrw) {
        super.parse(xrw);
        this.id = xrw.getInteger("ID");
        this.difficulty = xrw.getInteger("难度ID");
        this.level = xrw.getInteger("关卡ID");
        this.challengeStr = xrw.getString("挑战ID");
        this.rwdStr = xrw.getString("挑战奖励分组");
        this.insTplStr = xrw.getString("*怪物配置");
    }

    @NoteField(value = "挑战ID的list")
    public List<Integer> challengeIds = new ArrayList<>();

    @NoteField(value = "挑战对应的奖励")
    public List<Integer> rwdGroupIds = new ArrayList<>();

    @Override
    public void decode() {
        if (StringUtils.isNotBlank(challengeStr)) {
            challengeIds = Str.strArr2intList(challengeStr.split("#"));
        }

        if (StringUtils.isNotBlank(rwdStr)) {
            rwdGroupIds = Str.strArr2intList(rwdStr.split("#"));
        }
    }
}
